package com.qiezi.project.fragment;



import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.qiezi.App;
import com.qiezi.R;
import com.qiezi.base.BaseMvpFragment;
import com.qiezi.mvp.CreatePresenter;
import com.qiezi.project.activity.AboutActivity;
import com.qiezi.project.activity.CollectionActivity;
import com.qiezi.project.activity.DownloadActivity;
import com.qiezi.project.activity.InvitationActivity;
import com.qiezi.project.activity.SettingActivity;
import com.qiezi.project.activity.VipCenterActivity;
import com.qiezi.project.activity.WatchHistoryActivity;
import com.qiezi.project.adapter.CategoryAdapter;
import com.qiezi.project.contract.MyContract;
import com.qiezi.project.view.ItemButtonView;

import java.util.ArrayList;

import butterknife.BindView;

@CreatePresenter(presenter = MyContract.Presenter.class)
public class MyFragment extends BaseMvpFragment<MyContract.Presenter> implements MyContract.View,View.OnClickListener {

    @BindView(R.id.iv_user)
    ImageView ivUser;

    @BindView(R.id.tv_userName)
    TextView tvUserName;

    @BindView(R.id.tv_id)
    TextView tvID;

    @BindView(R.id.iv_openVip)
    ImageView ivOpenVip;

    @BindView(R.id.iv_share)
    ImageView ivShare;


    @BindView(R.id.ibv_history)
    ItemButtonView ibvHistory;

    @BindView(R.id.ibv_collection)
    ItemButtonView ibvCollection;

    @BindView(R.id.ibv_download)
    ItemButtonView ibvDownload;

    @BindView(R.id.ibv_about)
    ItemButtonView ibvAbout;

    @BindView(R.id.ibv_setting)
    ItemButtonView ibvSetting;

    @Override
    public int getLayoutRes() {
        return R.layout.fragment_my;
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        tvUserName.setText(App.getInstance().getUserName());
        tvID.setText("ID:"+App.getInstance().getUserID());
    }


    @Override
    protected void initListener() {
        ivOpenVip.setOnClickListener(this);
        ivShare.setOnClickListener(this);
        ibvHistory.setOnClickListener(this);
        ibvCollection.setOnClickListener(this);
        ibvDownload.setOnClickListener(this);
        ibvAbout.setOnClickListener(this);
        ibvSetting.setOnClickListener(this);
    }


    @Override
    public void resultData(ArrayList data) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_openVip:
                startActivity(new Intent(getActivity(),VipCenterActivity.class));
                break;
            case R.id.iv_share:
                startActivity(new Intent(getActivity(),InvitationActivity.class));
                break;
            case R.id.ibv_history:
                getActivity().startActivityForResult(new Intent(getActivity(),WatchHistoryActivity.class),WatchHistoryActivity.REQUEST_CODE);
                break;
            case R.id.ibv_collection:
                getActivity().startActivityForResult(new Intent(getActivity(),CollectionActivity.class),CollectionActivity.REQUEST_CODE);
                break;
            case R.id.ibv_download:
                getActivity().startActivityForResult(new Intent(getActivity(),DownloadActivity.class),DownloadActivity.REQUEST_CODE);
                break;
            case R.id.ibv_about:
                startActivity(new Intent(getActivity(),AboutActivity.class));
                break;
            case R.id.ibv_setting:
                startActivity(new Intent(getActivity(),SettingActivity.class));
                break;
        }
    }

}
